﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DTO;
namespace DAO
{
    public class ThamSoDAO
    {
        public DataTable LayTable()
        {
            String sql = "SELECT * from ThamSo ";
            SqlConnection con = DataProvider.ConnectDB();
            con.Open();
            SqlCommand command = new SqlCommand(sql, con);
            SqlDataAdapter adapter = new SqlDataAdapter(command);
            DataTable dt = new DataTable();
            adapter.Fill(dt);
            con.Close();
            return dt;
        }       

        public void sua(ThamSoDTO ts)
        {
            String sql = "UPDATE ThamSo SET SoLuongNhapToiThieu =" + ts.SoLuongNhapToiThieu + ",TonToiDa=" + ts.TonToiDa + ",SoLuongTon=" + ts.SoLuongTon + ",SoLuongTonQuyDinhNhap=" + ts.SoLuongTonQuyDinhNhap +",TienNoQuyDinh = " + ts.TienNoQuyDinh + ",TienNoCuaKhachHang =" + ts.TienNoCuaKH + ",SoLuongTonQuyDinhTruocKhiBan =" + ts.SoLuongTonQuyDinhTruocKhiBan + ",SoLuongTonQuyDinhSauKhiBan =" + ts.SoLuongTonQuyDinhSauKhiBan + "";
            SqlConnection con = DataProvider.ConnectDB();
            con.Open();
            SqlCommand command = new SqlCommand(sql, con);
            int res = -1;
            res = command.ExecuteNonQuery();
            con.Close();
        }
        public void xoa(ThamSoDTO ts)
        {
            String sql = "delete ThamSo";
            SqlConnection con = DataProvider.ConnectDB();
            SqlCommand command = new SqlCommand(sql, con);
            con.Open();
            int res = -1;
            res = command.ExecuteNonQuery();
            con.Close();
        }
    }
}

